package com.easy.dev.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.easy.dev.entity.TableConfig;
import com.easy.dev.mapper.TableConfigMapper;
import com.easy.dev.utils.ClassNameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TableConfigServiceImpl extends BaseServiceImpl<TableConfig>{

    @Autowired
    private TableConfigMapper tableConfigMapper;

    BaseMapper getMapper() {
        return this.tableConfigMapper;
    }

    public TableConfig getConfigByName(String tableName) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("name", ClassNameUtils.getUnderlineTableName(tableName));
        return tableConfigMapper.selectOne(wrapper);
    }
};